package com.bkgy.modular.configureRules.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bkgy.modular.configureRules.dto.AcidRollingLMN2130Dto;
import com.bkgy.modular.configureRules.entity.AcidRollingLMN2130;
import com.bkgy.modular.configureRules.mapper.AcidRollingLMN2130Mapper;
import com.bkgy.modular.configureRules.service.AcidRollingLMN2130Service;
import com.bkgy.sys.common.entity.ResultData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author
 * @version 1.0
 * @ClassName AcidRollingLMN2130ServiceImpl
 * @date 2023/4/20 10:53
 */
@Service
public class AcidRollingLMN2130ServiceImpl extends ServiceImpl<AcidRollingLMN2130Mapper, AcidRollingLMN2130> implements AcidRollingLMN2130Service {
    @Resource
    private AcidRollingLMN2130Mapper acidRollingLMN2130Mapper;

    @Override
    public ResultData queryAcidRollingLMN2130() {
        List<AcidRollingLMN2130> lmn2130List = acidRollingLMN2130Mapper.selectList(null);
        return ResultData.ResultDataFaultSelf("操作成功",lmn2130List);
    }

    @Override
    public ResultData updateAcidRollingLMN2130(AcidRollingLMN2130Dto dto) {
        Double yp_class = dto.getYp_class();
        Double l = dto.getL();
        Double m = dto.getM();
        Double n = dto.getN();
        if (yp_class == null) {
            return ResultData.ResultDataFaultSelf("参数有误,请检查参数",-1);
        }
        LambdaQueryWrapper<AcidRollingLMN2130> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AcidRollingLMN2130::getYp_class,yp_class);
        AcidRollingLMN2130 acidRollingLMN2130 = acidRollingLMN2130Mapper.selectOne(queryWrapper);
        if (acidRollingLMN2130 != null) {
            acidRollingLMN2130.setL(l);
            acidRollingLMN2130.setM(m);
            acidRollingLMN2130.setN(n);
            int flag = acidRollingLMN2130Mapper.update(acidRollingLMN2130, queryWrapper);
            if (flag == 1) {
                return ResultData.ResultDataFaultSelf("操作成功",1);
            }
        }
        return  ResultData.ResultDataFaultSelf("操作失败",-1);
    }
}
